package org.hijava.iplooking;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class IP {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
	@Persistent
	private long startIP;
	@Persistent
	private long endIP;
	@Persistent
	private String country;
	@Persistent
	private String area;

	public IP(String record) {
		String[] arr=record.split("\t");
		startIP=Utils.getIpNumber(arr[0].trim());
		endIP=Utils.getIpNumber(arr[1].trim());
		country=arr[2].trim();
		if(arr.length>=4){
			area=arr[3].trim();
		}
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public long getStartIP() {
		return startIP;
	}

	public void setStartIP(long startIP) {
		this.startIP = startIP;
	}

	public long getEndIP() {
		return endIP;
	}

	public void setEndIP(long endIP) {
		this.endIP = endIP;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}

}
